package Arithmetic;

import java.util.Scanner;

/**
 * Created by Administrator on 2017/5/12.
 */
public class OutputQuestionsToFile {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        MakeQuestions Nq = new MakeQuestions();
        IOFile iof = new IOFile("Exercises.txt");

        int count, level;
        int q = 0;
        String expr;

       while(true) {
           System.out.print("请输入要生成的题目数：");
           count = scan.nextInt();
           System.out.print("请输入生成题目的级别（每增加一级多一个运算符，最低为一级）：");
           level = scan.nextInt();
           System.out.println(" ");
           if (count > 0 && level > 0) {
               for (int i = 0; i < count; i++) {
                   //生成题目
                   int a;
                   a = i + 1;
                   expr = Nq.getExper(level);
                   String s = "题目" + a + ":" + expr + " = \n";
                   System.out.println(s);
                   iof.WriteQuestionsToFile(s);
               }
               break;
           } else {
               System.out.println("题目数和题目等级必须大于零!");
           }
       }
    }
}


